import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:app_settings_ohos/app_settings_ohos.dart';

void main() {
  TestWidgetsFlutterBinding.ensureInitialized();
  const MethodChannel methodChannel = MethodChannel('com.spencerccf.app_settings/methods');

  late List<MethodCall> log;
  setUp(() {
    log = <MethodCall>[];
    _ambiguate(TestDefaultBinaryMessengerBinding.instance)!
        .defaultBinaryMessenger
        .setMockMethodCallHandler(methodChannel, (MethodCall methodCall) async {
      log.add(methodCall);
      return null;
    });
  });

  test('wifi', () async {
    log = <MethodCall>[];
    AppSettings.openAppSettings(type: AppSettingsType.wifi);
  });

  test('nfc', () async {
    log = <MethodCall>[];
    AppSettings.openAppSettings(type: AppSettingsType.nfc);
  });

  test('location', () async {
    log = <MethodCall>[];
    AppSettings.openAppSettings(type: AppSettingsType.location);
  });

  test('bluetooth', () async {
    AppSettings.openAppSettings(type: AppSettingsType.bluetooth);
  });

  test('notification', () async {
    AppSettings.openAppSettings(type: AppSettingsType.notification);
  });

  test('display', () async {
    AppSettings.openAppSettings(type: AppSettingsType.display);
  });

  test('sound', () async {
    AppSettings.openAppSettings(type: AppSettingsType.sound);
  });

  test('date', () async {
    AppSettings.openAppSettings(type: AppSettingsType.date);
  });

  test('internalStorage', () async {
    AppSettings.openAppSettings(type: AppSettingsType.internalStorage);
  });

  test('developer', () async {
    AppSettings.openAppSettings(type: AppSettingsType.developer);
  });

  test('security', () async {
    AppSettings.openAppSettings(type: AppSettingsType.security);
  });

  test('accessibility', () async {
    AppSettings.openAppSettings(type: AppSettingsType.accessibility);
  });

  test('hotspot', () async {
    AppSettings.openAppSettings(type: AppSettingsType.hotspot);
  });

  test('settings', () async {
    AppSettings.openAppSettings(type: AppSettingsType.settings);
  });

  test('device', () async {
    AppSettings.openAppSettings(type: AppSettingsType.device);
  });

  test('batteryOptimization', () async {
    AppSettings.openAppSettings(type: AppSettingsType.batteryOptimization);
  });
}
T? _ambiguate<T>(T? value) => value;

